package com.sds.sweng.swat.miplatform.ui.design.models.area.sub;

import org.codehaus.jackson.annotate.JsonIgnore;

public abstract class TableCellSubArea extends SubArea {

	protected int type;

	public static final int
		TYPE_LABEL = 0,
		TYPE_COMPONENTS = 1;

	public static final int DEFALT_HEIGHT = 26;

	protected int col;
	protected int row;
	protected int colspan;
	protected int rowspan = 1;
	protected String halign = HALIGN_LEFT;
	protected String valign = VALIGN_MIDDLE;

	public static final String
		HALIGN_LEFT = "Left",
		HALIGN_CENTER = "Center",
		HALIGN_RIGHT = "Right",
		VALIGN_TOP = "Top",
		VALIGN_MIDDLE = "Middle",
		VALIGN_BOTTOM = "Bottom";

	public static final String[] HALIGN = {
		HALIGN_LEFT,
		HALIGN_CENTER,
		HALIGN_RIGHT
	};

	public static final String[] VALIGN = {
		VALIGN_TOP,
		VALIGN_MIDDLE,
		VALIGN_BOTTOM
	};

	public TableCellSubArea() {

	}

	public TableCellSubArea(int col, int row, int width, int colspan) {
		this.col = col;
		this.row = row;
		this.width = width;
		this.colspan = colspan;
		this.height = DEFALT_HEIGHT;
	}

	public TableCellSubArea clone() {
		TableCellSubArea clone = (TableCellSubArea) super.clone();
		clone.setCol(getCol());
		clone.setRow(getRow());
		clone.setColspan(getColspan());
		clone.setRowspan(getRowspan());
		clone.setHalign(getHalign());
		clone.setValign(getValign());

		return clone;
	}

	public int getCol() {
		return col;
	}

	public void setCol(int col) {
		this.col = col;
	}

	public int getRow() {
		return row;
	}

	public void setRow(int row) {
		this.row = row;
	}

	public int getColspan() {
		return colspan;
	}

	public void setColspan(int colspan) {
		this.colspan = colspan;
	}

	public int getRowspan() {
		return rowspan;
	}

	public void setRowspan(int rowspan) {
		this.rowspan = rowspan;
	}

	public String getHalign() {
		return halign;
	}

	public void setHalign(String halign) {
		this.halign = halign;
	}

	public String getValign() {
		return valign;
	}

	public void setValign(String valign) {
		this.valign = valign;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public abstract boolean isEmpty();

	@JsonIgnore
	public boolean isFirstCell() {
		if (getCol() == 0)
			return true;

		return false;
	}

	@JsonIgnore
	public boolean isLastCell() {
		return false;
	}

}
